package com.eamois.ui.util;

import java.awt.Color;
import java.awt.Component;
import java.util.Collection;

import javax.swing.ImageIcon;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;

import com.eamois.action.manual.ManualAction;
import com.eamois.action.manual.TechnologyAction;
import com.eamois.domain.manual.Manual;
import com.eamois.domain.manual.ManualEnsip;
import com.eamois.domain.manual.Technology;

public class EnsipTreeRenderer extends DefaultTreeCellRenderer{
	public EnsipTreeRenderer() {
		
	}
	
	public Component getTreeCellRendererComponent(JTree tree, Object value,
			boolean sel, boolean expanded, boolean leaf, int row,
			boolean hasFocus) {
		super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf,
				row, hasFocus);
		DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
//		if (node.isRoot()) {
//			setIcon(new ImageIcon(com.eamois.icon.GetIcons.class
//					.getResource("part.png")));			
//		}else {
//			setIcon(new ImageIcon(com.eamois.icon.GetIcons.class
//					.getResource("equipment_detail.png")));			
//		}
		if (node.isRoot()) {
			setIcon(new ImageIcon(com.eamois.icon.GetIcons.class.getResource("engine.png")));			
		}else {
			setIcon(new ImageIcon(com.eamois.icon.GetIcons.class.getResource("part.png")));			
		}
		
		if(node.isLeaf()&&node.getUserObject() instanceof ManualEnsip){
			
//			ManualEnsip ensip=(ManualEnsip)node.getUserObject();
//			Manual manual = new ManualAction().getManualByEngine(ensip.getManualEngine());
//			Collection<Technology> technologys =(Collection<Technology>)new TechnologyAction().getTechnologyByEnsipAndManual(ensip, manual);
//			if(technologys!=null&&technologys.size()!=0){
//				setForeground(Color.BLUE);
//			}
		}
		return this;
	}
}
